<?php
/**
 * @uses 	写日志文件
 * @param 	string $dir 目录
 * @param 	string $filename 文件名
 * @param 	string $fileContent 内容
 * @return 	boolen
 */
function writeLog($dir,$filename,$fileContent){
    \Org\Util\File::createDir($dir);
    return @file_put_contents($dir.$filename.'.log', $fileContent);
}

/**
 * @uses 	curl
 * @param   $url 	url链接
 * @param 	$data 	数据
 * @return 	
 */
function curlPost($url , $data = [])
{
	$ch = curl_init ();
	curl_setopt($ch , CURLOPT_URL , $url);
	curl_setopt($ch , CURLOPT_HEADER , 0);
	curl_setopt($ch , CURLOPT_TIMEOUT , C('TIMEOUT'));
	if ($data)	{
		curl_setopt($ch , CURLOPT_POST , true);
		curl_setopt($ch , CURLOPT_POSTFIELDS , $data);
	}
	curl_setopt($ch , CURLOPT_RETURNTRANSFER , true);
	$return 	= curl_exec($ch);
	$httpCode   = curl_getinfo($ch , CURLINFO_HTTP_CODE);
    curl_close($ch); 
    if ($httpCode !== 200) {
        return ['code' => 504];
    }
    $result = json_decode($return , true);
    return $result;
}

